package com.ideaction.game.utils;

public class TextKit {
	/**
	 * 将字符串数组转换为char数组
	 * 
	 * @param strs
	 * @return
	 */
	public static char[] parseCharArray(String[] strs) {
		if (strs == null)
			return null;
		char[] array = new char[strs.length];
		for (int i = 0; i < strs.length; i++)
			array[i] = strs[i].charAt(0);
		return array;
	}

	/**
	 * 将字符串数组转换为byte数组
	 * 
	 * @param strs
	 * @return
	 */
	public static boolean[] parseBooleanArray(String[] strs) {
		if (strs == null)
			return null;
		boolean[] array = new boolean[strs.length];
		for (int i = 0; i < strs.length; i++)
			array[i] = Boolean.valueOf(strs[i]);
		return array;
	}

	/**
	 * 将字符串数组转换为byte数组
	 * 
	 * @param strs
	 * @return
	 */
	public static byte[] parseByteArray(String[] strs) {
		if (strs == null)
			return null;
		byte[] array = new byte[strs.length];
		for (int i = 0; i < strs.length; i++)
			array[i] = Byte.valueOf(strs[i]);
		return array;
	}

	/**
	 * 将字符串数组转换为short数组
	 * 
	 * @param strs
	 * @return
	 */
	public static short[] parseShortArray(String[] strs) {
		if (strs == null)
			return null;
		short[] array = new short[strs.length];
		for (int i = 0; i < strs.length; i++)
			array[i] = Short.valueOf(strs[i]);
		return array;
	}

	/**
	 * 将字符串数组转换为int数组
	 * 
	 * @param strs
	 * @return
	 */
	public static int[] parseIntArray(String[] strs) {
		if (strs == null)
			return null;
		int[] array = new int[strs.length];
		for (int i = 0; i < strs.length; i++)
			array[i] = Integer.valueOf(strs[i]);
		return array;
	}

	/**
	 * 将字符串数组转换为long数组
	 * 
	 * @param strs
	 * @return
	 */
	public static long[] parseLongArray(String[] strs) {
		if (strs == null)
			return null;
		long[] array = new long[strs.length];
		for (int i = 0; i < strs.length; i++)
			array[i] = Long.valueOf(strs[i]);
		return array;
	}

	/**
	 * 将字符串数组转换为float数组
	 * 
	 * @param strs
	 * @return
	 */
	public static float[] parseFloatArray(String[] strs) {
		if (strs == null)
			return null;
		float[] array = new float[strs.length];
		for (int i = 0; i < strs.length; i++)
			array[i] = Float.parseFloat(strs[i]);
		return array;
	}

	/**
	 * 将字符串数组转换为double数组
	 * 
	 * @param strs
	 * @return
	 */
	public static double[] parseDoubleArray(String[] strs) {
		if (strs == null)
			return null;
		double[] array = new double[strs.length];
		for (int i = 0; i < strs.length; i++)
			array[i] = Double.parseDouble(strs[i]);
		return array;
	}
}
